<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../baselayout/import.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="${staticPath}/assets/css/bootstrap.min.css">
<link rel="stylesheet" href="${staticPath}/assets/css/fp-index.css">
<script src="${staticPath}/assets/js/modernizr-latest.js"></script>
<script src="${staticPath}/js/jQuery-1.9.1.js"></script>
<script src="${staticPath}/js/angular.min.js"></script>
<script src=""></script>
<title>数据显示</title>
<style>
.Hide{
display:none;
}
.Show{
display:block;
}
td,th{
text-align:center;
}
a{
text-align:center;
}
</style>
</head>
<body>
<div ng-app="myApp1" >
	<div class="container-fluid" ng-controller="myCtrl1">
	<c:choose>
			<c:when test="${isExist}">
			    <div class="header">
	  			    <div class="tip">
					    <h2 style="color:green">您查询的变量存在如下：</h2>
						<c:choose>
							<c:when test="${isMapAndSet}">
								<table class="table table-hover">
								<thead id="thead">
								</thead>
								<tbody id="tbody">
								</tbody >
								</table>
							</c:when>
							<c:otherwise>
								<samp><p style="font-size:25px;margin-left:30px">${result}</p></samp>
							</c:otherwise>
					   </c:choose>
				      <div class="row row1">
				            <div id="Index"  class=" col-md-6 col-md-offset-3 col-xs-12 text-center">	
				            	<a class="btn btn-default" ng-href="${staticPath}/fp/ctxIntrospect.do?Start={{start}}&Size={{PageSize}}" ng-disabled="true">首页</a>
                   				<a class="btn btn-default" ng-href="${staticPath}/fp/ctxIntrospect.do?Start={{start}}&Size={{PageSize}}" ng-disabled="false">上一页</a>
                                <input style="border:none;text-align:center" ng-model="str"/>
                   				<a class="btn btn-default" ng-href="${staticPath}/fp/ctxIntrospect.do?Start={{start}}&Size={{PageSize}}" ng-disabled="hasNext()">下一页</a>
                   				<a class="btn btn-default" ng-href="${staticPath}/fp/ctxIntrospect.do?Start={{start}}&Size={{PageSize}}" ng-disabled="isEnd()">尾页</a>
				            </div>
				       </div>
				       <div class="row row2">
				            <div class="col-md-2 col-md-offset-10 text-center">
		        	             <a href="./train.do" class="btn btn-success">返回</a>
		                    </div>
		               </div>
			       </div>
		        </div>			
            </c:when>
            <c:otherwise>
    			<div class="header">
					<div class="tip">
						<h2 style="color:red">您查询的变量不存在</h2>
				        <a href="./train.do" class="btn btn-warning">返回</a>
					</div>
				</div>
      	   </c:otherwise>
	   </c:choose>
	</div>
</div>
<script> 
	var arr1 = new Array(); 
	var name="${name}";
	var isSet="${isSet}";
	var isMap="${isMap}";
	var ketset="${keyset}";
	var result;
	var result2= new Array();
	var result3;
	var str1="<tr>";
	var str2="<tr>";
	var number = new Array();
	var count=0;
	if(name=="termTable"){
	arr1=["label","doc","word","term"];
		result=ketset.replace('[','').split('],');
		for(var j=0;j<result.length;j++)
		{
			if(result[j].substr(2,1).match(/\d/)!=null)
	    	{
			    number[count]=j;
     			count++;
			}
		} 
 		var myApp = angular.module('myApp1', []);
		myApp.controller('myCtrl1',['$scope', function($scope){
		$scope.newPage = 0;
        $scope.allSize = number.length;
        $scope.PageSize=200;
        if($scope.newPage==0)
        {
	    	$scope.start=0;
	    	$scope.PageSize=number[$scope.newPage];
	    }
	    else
	    {
	    	$scope.start=number[$scope.newPage-1];
	    	if($scope.newPage==$scope.allSize)
	    	{
	   			$scope.PageSize=result.length;
	    	}
	   		else
	   		{
	   			$scope.PageSize=number[$scope.newPage];
	   		}
	    } 
        $scope.str=$scope.newPage+1+"/"+($scope.allSize+1); 
        
		}]);	
	}
	else if(name=="invertedTable"){
	var myApp = angular.module('myApp1', []);
    myApp.controller('myCtrl1',['$scope', function($scope) {
    $scope.newPage = 0;
    $scope.allsize = 100;
    $scope.PageSize = 10;
     $scope.str=$scope.newPage+1+"/"+($scope.allSize+1);  
    }]);
		}
	else if(name=="idToLabelMap"){
		arr1=["labelId","label"];
		result=ketset.replace(/\[/g,'').replace(/\]/g,'').split(',');
	}
	else if(name=="labelToIdMap"){
		arr1=["label","labelId"];
		result=ketset.replace(/\[/g,'').replace(/\]/g,'').split(',');
	}
	else if(name=="featuredTerms")
	{
		arr1=["word","idf"];
		result=ketset.replace(/\[/g,'').replace(/\]/g,'').split(',');
	}
	else{
		arr1="";
		result=ketset.replace(/\[/g,'').replace(/\]/g,'').split(',');
	}
   for(var i=0;i<arr1.length;i++)
   {
        str1+="<th>"+arr1[i]+"</th>";
   }
   str1+="</tr>";
  var head = document.getElementById("thead");
  head.innerHTML=str1;
   if(isSet=="true"){
	var myApp = angular.module('myApp1', []);
    myApp.controller('myCtrl1',['$scope', function($scope) {
    $scope.newPage = 0;
    $scope.allsize = 100;
    $scope.PageSize = 10; 
     $scope.str=$scope.newPage+1+"/"+($scope.allSize+1); 
}]);
}
   else if(isMap=="true"){
		switch(name)
		{
			case "labelToIdMap":
			case "idToLabelMap":
  				for(var i=0;i<result.length;i++)
				{
					str2+="<td>"+result[i]+"</td><td>"+result[i+1]+"</td></tr><tr>";
					i=i+1;
				}
				str2+="<tr>";
				document.getElementById("tbody").innerHTML=str2;
  			break;
			default:
       }
   }
</script>
</body>
</html>

